﻿using System.Collections.ObjectModel;
using System.Data.SqlClient;

namespace Libraries.Repositories
{
    public class RolePermissionRepository
    {

        public bool CheckRole(string accountName, string functionId)
        {
            var parameters = new Collection<SqlParameter>
                                                      {
                                                          new SqlParameter("@AccountName",accountName),
                                                          new SqlParameter("@FunctionId",functionId)
                                                      };

            if (!string.IsNullOrEmpty(ProcedureConfiguration.CheckRole))
            {
                using (var result = RepositorySql.SqlHelper.ExecuteReader(ProcedureConfiguration.CheckRole, parameters, ConnectionConfiguration.ConnectionString))
                {
                    if (result.Read())
                    {
                        return true;
                    }
                }
            }
            return false;
        }
    }
}
